package com.lyeducation.security.config;

import com.alibaba.fastjson.JSON;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;

public abstract class AbstractJsonException {
    protected void jsonException(HttpServletResponse httpServletResponse,Exception e) throws IOException {
        httpServletResponse.setContentType("application/json;charset=UTF-8");
        HashMap<String,String> paramMap=new HashMap<>(2);
        paramMap.put("status","error");
        paramMap.put("msg",e.getMessage());
        httpServletResponse.getWriter().println( JSON.toJSONString(paramMap));
    }
}
